<template id="vocationList">
  <div>
    <van-swipe-cell :before-close="beforeClose">
      <div class="_item" @click="link_bank">
        <div class="right_item">
          <div class="item_row clearfix">
            <span class="job_name">{{data.gwmc}}</span>
            <span class="job_money overflow">
              <span class="num">{{data.yxfw}}</span>
            </span>
          </div>
          <div class="item_row last_row clearfix" :class="[!data.sfdwxx?'':'last_row']">
            <span class="jobName">招聘人数 {{data.zrs}}人 | {{data.ygxs}}</span>
            <span class="jobDate">{{data.fbsj}}</span>
          </div>
        </div>
      </div>
      <template #right v-if="visibleSlide">
        <van-button square text="延期" type="danger" @click="yqFn(3)" class="slide-button yq"/>
        <van-button square text="停招" type="danger" @click="yqFn(0)" class="slide-button"/>
      </template>
    </van-swipe-cell>
  </div>
</template>
<script>
import viewNum from "@/common/js/configuration";
export default {
  name: "vocationList",
  props: {
    data: {
      type: Object
    },
    visibleSlide: {
      type: Boolean
    },
    slideText: {
      type: String,
      default: "删除"
    }
  },
  methods: {
    beforeClose({ position, instance }) {
      switch (position) {
        case "outside":
          instance.close();
          break;
      }
    },
    yqFn(num) {
      let text = num == 0 ? "停招" : "延期";
      this.$confirm(`确定要${text}当前职位吗？`, "提示")
        .then(() => {
          this.$loading = true;
          this.$http({
            url: "/dwgl/gwztBc",
            method: "post",
            data: {
              ywcz: num,
              dwdjid: this.data.dwdjid,
              zpgwid: this.data.zpgwid
            }
          }).finally(() => {
          this.$loading = false;
        }).then(res => {
            let _res = res.returnData;
            if (+_res.executeResult == 1) {
              this.$alert({
                message: _res.message || '操作成功!',
                cb:()=>{
                  this.$emit("refresh",num);
                }
              });
            } else {
              this.$alert({
                message: _res.message || '操作失败！',
                cb:()=>{
                  this.$emit("refresh",num);
                }
              });
            }
          });
        })
        .catch(() => {})

    },

    link_bank() {
      this.$emit("link", this.data.zpgwid);
    }
  }
};
</script>
<style lang="scss" scoped>
@import "~common/scss/var.scss";
._item {
  margin: $height-base/10 0;
  border-radius: $radius-base3;
  background-color: #fff;
  flex-wrap: wrap;
  .right_item {
    padding: 33px 32px;
    box-sizing: border-box;
    .item_row {
      margin-bottom: 14px;
      color: #4d4d4d;
      display: flex;
      .job_name {
        font-weight: 400;
        font-size: 34px;
        flex: 1;
      }
      .job_money {
        width: 200px;
        color: #817e81;
        font-size: $font-size-small;
        width: 42%;
        text-align: right;
        word-wrap: break-word;
        .num {
          color: #fb4d64;
          // font-size: $font-size-large;
          font-size: $font-size-base;
        }
      }
      .jobName {
        flex: 1;
        font-size: $font-size-small;
        color: $color-text-label;
        margin-top: 16px;
      }
      .jobDate {
        width: 333px;
        font-size: $font-size-small;
        color: $color-text-label;
        margin-top: 16px;
        text-align: right;
      }
    }
    .last_row {
      margin-bottom: 0;
    }
  }
}
._item:first-child {
  margin-top: 0;
}
/deep/ .van-swipe-cell__right button {
  height: 100%;
}
.slide-button {
  background-color: #e86060;
  border: 1px solid #e86060;
  .van-button__text {
    font-size: 28px;
  }
}
.yq{
  background-color: #6CABCA;
  border: 1px solid #6CABCA;
}
/deep/ .van-button--normal {
  padding: 0 30px;
}
</style>
